// kanbanLocal.js 看板本地存储操作工具，包含看板信息的增删查改等方法
const STORAGE_KEY = 'kanbanxinxi';

export function getKanbanList() {
  return JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
}

export function saveKanbanList(list) {
  localStorage.setItem(STORAGE_KEY, JSON.stringify(list));
}

export function addKanban(item) {
  const list = getKanbanList();
  item.id = Date.now();
  list.push(item);
  saveKanbanList(list);
}

export function updateKanban(item) {
  const list = getKanbanList();
  const idx = list.findIndex(i => i.id === item.id);
  if (idx !== -1) {
    list[idx] = item;
    saveKanbanList(list);
  }
}

export function deleteKanban(ids) {
  let list = getKanbanList();
  list = list.filter(i => !ids.includes(i.id));
  saveKanbanList(list);
}

export function getKanbanById(id) {
  return getKanbanList().find(i => i.id === id);
} 